#ifndef STORAGE_CONNECTION_CONFIG_HPP
#define STORAGE_CONNECTION_CONFIG_HPP

#include "Storage/CommonStorageConfig.hpp"
#include <iosfwd>
#include <string>
#include <map>

namespace Storage
{

/// \ingroup Storage
/// \brief It holds the information regarding a connection configuration.
class COMMON_STORAGE_API ConnectionConfig
{
public:
	/// \brief It initializes the name of the connection.
	ConnectionConfig( const NameString& typeName, const NameString& name);
	
	/// \brief Dummy destructor
	virtual ~ConnectionConfig();

	/// \brief It gets the name of the configuration.
	const NameString& name() const { return name_; }

	/// \brief It sets the name of the configuration.
	void setName( const NameString& newName) { name_ = newName; }

	/// \brief It gets the name of the connection type.
	const NameString& typeName() const { return typeName_; }

	/// \brief It stores the configuration data to the specified stream.
	virtual void store( std::ostream& os);

	/// \brief It loads the configuration data from the specified stream. It should assume that the name of the 
	///		configuration is already loaded and only the rest of the attributes need to be loaded.
	virtual void load( std::istream& is);

private:
	NameString name_;
	NameString typeName_;

protected:
	typedef std::map< NameString, String> AttributeCollection;
	AttributeCollection attributes_;
};

/// \ingroup Storage
/// \brief It creates a connection configuration of the specified type, having the specified connection name.
/// \param ConnT the type of the connection configuration to create.
/// \param name the name of the connection configuration.
template< typename ConnT>
ConnT* createConnectionConfig( const NameString& name)
{
	return new ConnT( name);
}

} // namespace Storage

#endif // STORAGE_CONNECTION_CONFIG_HPP
